package test;

import Util.javautil1;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class zuoye {
    public static void main(String[] args) throws SQLException,ClassNotFoundException {
       //增
        String sql="insert into job values(?,?,?,?,?,?)";
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入你的编号");
        int jno=scanner.nextInt();
        System.out.println("请输入你的姓名");
        String jname=scanner.next();
        System.out.println("请输入你的性别");
        String jsex=scanner.next();
        System.out.println("请输入你的年龄");
        int jage=scanner.nextInt();
        System.out.println("请输入你的部门编号");
        int jdept=scanner.nextInt();
        System.out.println("请输入你的部门名称");
        String jdeptname=scanner.next();
        List list=new ArrayList<>();
        list.add(jno);
        list.add(jname);
        list.add(jsex);
        list.add(jage);
        list.add(jdept);
        list.add(jdeptname);
        int num = javautil1.excuteupdate(sql,list.toArray());
        if(num>0){
            System.out.println("添加成功");
        }else {
            System.out.println("添加失败");
        }
        String sql1="update job set jage=? where jname='王五'";
        System.out.println("请输入修改后的年龄");
        int jage1= scanner.nextInt();
        List list1=new ArrayList();
        list1.add(jage1);
        int num1=javautil1.excuteupdate(sql1, list1.toArray());
        if (num1>0){
            System.out.println("修改成功");
        }else {
            System.out.println("修改失败");
        }
        //查
        String sql2="select jname from job where jdeptname='机密'";
        ResultSet rs=javautil1.excutquery(sql2,list.toArray());
        while (rs.next()){
            System.out.println(rs.getObject("jname"));
        }
        String sql3="delete from job where jno=11";
        int num3=javautil1.excuteupdate(sql3,list.toArray());
        if(num3>0){
            System.out.println("删除成功");
        }else {
            System.out.println("删除失败");
        }
        javautil1.close();
    }
}
